package com.itheima.zuoye;

import java.util.ArrayList;
import java.util.List;

public class Test4 {
    //    测试类中，创建若干SUV对象，保存到集合，遍历集合，输出中型SUV。
    public static void main(String[] args) {
        SUV s1 = new SUV();
        s1.setBrand("奔驰");
        s1.setLength(4500);
        s1.setPrice(100.0);
        SUV s2 = new SUV();
        s2.setBrand("宝马");
        s2.setLength(4000);
        s2.setPrice(80.0);
        SUV s3 = new SUV();
        s3.setBrand("奥迪");
        s3.setLength(4200);
        s3.setPrice(90.0);

        ArrayList<SUV> list = new ArrayList<>();
        list.add(s1);
        list.add(s2);
        list.add(s3);

//    遍历集合，输出中型SUV
        int   a;
        for (int i = 0; i < list.size(); i++) {
            SUV s = list.get(i);
           a= s.judge();
           if (a==2){
               System.out.println(s.brand+"是中型SUV");
           }
           }
    }
}

